program DistRay;

{$APPTYPE CONSOLE}
var
a1, b1, c1, a2, b2, c2 : real;
x1, y1, x2, y2, x3, y3, x4, y4 : real;
xc : real;
d : real;
xp, yp : real;
dist : real;
begin
  readln(x1, y1);
  readln(x2, y2);
  readln(x3, y3);
  readln(x4, y4);
  a1 := y1-y2;
  b1 := x2-x1;
  c1 := x1*y2-x2*y1;
  a2 := y3-y4;
  b2 := x4-x3;
  c2 := x3*y4-x4*y3;

  xc := (c2*b1-c1*b2)/(a1*b2-b1*a2);

  if ((xc-x1)*(x2-x1)>=0)and((xc-x3)*(x4-x3)>=0) then
  begin
    dist := 0;
  end
  else
  begin
    d := (a2*x1+b2*y1+c2)/(a2*a2+b2*b2);
    xp := x1 - a2*d;
    yp := y1 - b2*d;
    if ((xp-x3)*(x4-x3)>=0) and((yp-y3)*(y4-y3)>=0) then
    begin
      dist := abs(d);
    end
    else
    begin
      d := (a1*x3+b1*y3+c1)/(a1*a1+b1*b1);
      xp := x3 - a1*d;
        if ((xp-x1)*(x2-x1)>=0) and ((yp-y1)*(y2-y1)>=0) then
        begin
          dist := abs(d);
          writeln('ee');
        end
        else
        begin
          dist := sqrt((y1-y3)*(y1-y3)+(x1-x3)*(x1-x3));
        end;
    end;
  end;
  writeln(dist:0:3);
end.
 